namespace imitateMacQQ.WebApi.Domain.Request.utils;

public class Request<T>
{
    // ReSharper disable once UnusedAutoPropertyAccessor.Global
    public DateTime AskTime { get; set; }

    // ReSharper disable once UnusedAutoPropertyAccessor.Global
    public bool Success { get; set; }

    // ReSharper disable once UnusedAutoPropertyAccessor.Global
    public T? Data { get; set; }

    // ReSharper disable once UnusedAutoPropertyAccessor.Global
    public string? Message { get; set; }

    /// <summary>
    /// 统一返回类型
    /// </summary>
    /// <param name="data">数据本体</param>
    /// <param name="success">服务器内部操作结果</param>
    /// <param name="message">反馈信息（服务器执行方法失败后返回）</param>
    /// <returns></returns>
    public static Request<T> Ok(T data, 
        bool success = true, 
        string message = "Request Success")
    {
        return new Request<T>()
        {
            Success = success,
            AskTime = DateTime.Now,
            Data = data,
            Message = message
        };
    }
}